<?php
namespace app\index\controller;

use app\common\controller\BaseController;
use qrcode\Qrcode;
use util\Wxsdk;
use wxpay\GetCert;
use wxpay\PayVthree;
use app\carpark\model\Carpark;
use app\merch\model\Token;
use util\Elind;
use think\facade\Cookie;
use speaker\Linkall;
class Index extends BaseController
{
    public function index()
    {
		// $elind = new Elind();
		// dump($elind->printTxt());
		// exit;
		// $token = new Token();
		// dump($token->getInfo('elind'));
		// exit;
		// $speaker = new Linkall(21031801);
		// return $speaker->bind(3);
		return redirect(real_url('mall/index/index'));
		$number = 2;
		$str = 'Shanghai';
		$txt = sprintf('There are %u million cars in %s.',$number,$str);
// 		$carpark = new Carpark;
// 		$return = $carpark->sendPost(1, 'https://api.drzk.cn/v2/car/temporarycar/payment/parkid/', json_decode('{ 
// "carNo":"粤Z76760",
// "entryTime":"2017-12-12 15:33:27",
// "payTime":"2017-12-14 14:54:27",
// "chargeDuration":2827,
// "amount":"48.00",
// "purchaseAmount":"44",
// "couponAmount":"4.00",
// "paymentType":"0",
// "paymentTnx":"4557125456841",
// "operator":"sssa"
// }', true));
// 		dump($return);
// 		exit;
		$pay = new PayVthree();
		$return = $pay->transactions(['out_trade_no' => 202103132299]);
		dump($return);
		exit;
		$time = time();
		$cert = Cert::where('effective_time', '<', $time)->where('expire_time', '>', $time)->find();
		$dir = null;
		if($cert){
			if (is_file(root_path().$cert['dir'])) $dir = $cert['dir'];
		} 
		$getcert = new GetCert($dir);
		$cert = $getcert->downloadCert();
		return $cert;
		if($jssdk['code'] == 1) $this->assign('jssdk', $jssdk);
		$qrcode = new Qrcode;
		return $qrcode->make('http://www.zzmind.com', 13, 7);
		$request = 123;
		dump($request);
    }

    public function hello()
    {
		// $elind = new Elind();
		// dump($elind->deletePrinter(4004575282));
		// exit;
		$carpark = new Carpark;
		$return = $carpark->sendGet(5, 'https://api.drzk.cn/v2/park/barriergate/parkid/');
		dump($return);
    }
}
